//
//  FriendSelCell.m
//  FootPrint
//
//  Created by alex tao on 4/9/13.
//  Copyright (c) 2013 alex tao. All rights reserved.
//

#import "FriendSelCell.h"

@implementation FriendSelCell

- (void)internalInit
{
    [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil];
    
    _realView.frame = self.bounds;
    [self.contentView addSubview:_realView];
    
    self.contentView.backgroundColor = [UIColor clearColor];
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        [self internalInit];
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:NO];

    // Configure the view for the selected state
}

- (void)dealloc {
    [_realView release];
    [_iconImage release];
    [_nameTitle release];
    [_redioImage release];
    [super dealloc];
}

- (void) updateUserMsg:(UserMessage*)msg
{
    _nameTitle.text = msg.nickName;
    if (!msg.portrait.isSys) {
        [_iconImage loadAsyncImage:msg.portrait.imageUrl];
    } else {
        [_iconImage setSysImageWithId:msg.portrait.id];
    }
}

- (void) updateCellInfo:(FriendQueryResponseMessage_FriendList*)msg
{
    _nameTitle.text = msg.user.nickName;
    if (!msg.user.portrait.isSys) {
        [_iconImage loadAsyncImage:msg.user.portrait.imageUrl];
    } else {
        [_iconImage setSysImageWithId:msg.user.portrait.id];
    }
}

- (void) updateCellGroupInfo:(GroupMessage*)msg
{
    _nameTitle.text = msg.name;
    if (!msg.image.isSys) {
        [_iconImage loadAsyncImage:msg.image.imageUrl];
    } else {
        [_iconImage setSysImageWithId:msg.image.id];
    }
}

@end
